//
//  DHCustomTextView.m
//  YDAPP
//
//  Created by tyxd on 17/2/10.
//  Copyright © 2017年 TYXD. All rights reserved.
//

#import "DHCustomTextView.h"
@interface DHCustomTextView ()<UITextViewDelegate>

@end

@implementation DHCustomTextView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        
        
        [self creatView];
        self.font = [UIFont systemFontOfSize:15];
        self.delegate = self;
        
        
    }
    return self;
}

-(void)creatView
{
    self.placeLable = [[UILabel alloc]init];
    
    _placeLable.numberOfLines = 0;
    
    _placeLable.textColor = [UIColor darkGrayColor];
    
    _placeLable.font = [UIFont systemFontOfSize:15];
    
    [self addSubview:_placeLable];
    
    //下面提示
    self.toolPlaceLable = [[UILabel alloc]init];
    
    _toolPlaceLable.numberOfLines = 0;
    
    _toolPlaceLable.textAlignment = NSTextAlignmentRight;
    
    _toolPlaceLable.textColor = [UIColor darkGrayColor];
    
    _toolPlaceLable.font = [UIFont systemFontOfSize:15];
    
    
    
    [self addSubview:_toolPlaceLable];
    
    //横线
    self.lineView = [[UIView alloc]init];
    
    self.lineView.backgroundColor = CSColorFromRGB(0xe6e6e6);
    
    [self addSubview:self.lineView];
    
    [self mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.height.mas_equalTo(100);
        
    }];
    
    [self.placeLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self).offset(5);
        make.top.mas_equalTo(self).offset(7);
        
        
    }];
    
    [self.toolPlaceLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(self).offset(kScreenWidth - 50);
        make.top.mas_equalTo(self).offset(self.frame.size.height-30);
        
    }];
    
    [self.lineView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self).offset(self.frame.size.height - 1);
        
        make.left.mas_equalTo(self).offset(10);
        
        make.right.mas_equalTo(self);
        
        make.height.mas_equalTo(1);
        
        
    }];
    
}


-(void)textViewDidChange:(UITextView *)textView
{
    if (self.text.length == 0) {
        self.placeLable.hidden = NO;
    }else
    {
        self.placeLable.hidden = YES;
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
